<script lang="ts" setup>
import { ref } from 'vue'
import { useI18n } from '@/hooks/useI18n'
const { t } = useI18n()


// 引用声明
defineProps({
  form: {
    type: Object,
    required: true
  }
})

// 引用事件
const emits = defineEmits(['search', 'reset'])

const formRef = ref()

// 确定搜索
const onFinish = () => {
  emits('search')
}

const handleReset = (formEl) => {
  if (!formEl) return
  formEl.resetFields()
  emits('search')
}


const options = [
  {
    label: t('common.roles.operateManage'),
    value: '102'
  },
  //   {
  //     label: "对接人",
  //     value: "116",
  //   },
  {
    label: t('common.roles.productManage'),
    value: '107'
  },
  {
    label: t('common.roles.doctor'),
    value: '101'
  },
  //   {
  //     label: "医生助理",
  //     value: "114",
  //   },
  {
    label:  t('common.roles.hospital'),
    value: '108'
  },
  {
    label:   t('common.roles.department'),
    value: '109'
  },
  {
    label:  t('common.roles.channel'),
    value: '111'
  },
  {
    label:  t('common.roles.business'),
    value: '110'
  },
  {
    label: t('common.roles.secondProducer'),
    value: '113'
  },
  //   {
  //     label: "超级管理员",
  //     value: "1",
  //   },
  //   {
  //     label: "其他角色",
  //     value: "115",
  //   },
  {
    label: t('common.roles.topicCreator'),
    value: '116'
  },
  //   {
  //     label: "卫健委",
  //     value: "117",
  //   },
  {
    label: t('common.roles.pharmaceuticalCompanies'),
    value: '118'
  },
  {
    label: t('common.roles.totalAccounts'),
    value: '119'
  }
]
</script>

<template>
  <a-card class="mb-3">
    <a-form
      ref="formRef"
      :model="form"
      layout="inline"
      @finish="onFinish"
    >
      <a-form-item :label="$t('routes.user.userName')" name="nickName">
        <a-input
          v-model:value="form.nickName"
          :placeholder="$t('routes.user.userPlaceholder')"
        />
      </a-form-item>

      <a-form-item :label="$t('routes.user.userPhone')" name="phone">
        <a-input
          v-model:value="form.phone"
          :placeholder="$t('routes.user.phonePlaceholder')"
        />
      </a-form-item>

      <a-form-item :label="$t('routes.user.userRole')" name="roleId">
        <a-select
          v-model:value="form.roleId"
          :options="options"
          :placeholder="$t('routes.user.rolePlaceholder')"
          style="width: 220px;"
          @change="onFinish"
        >
        </a-select>
      </a-form-item>


      <a-form-item>
        <a-space>
          <a-button html-type="submit" type="primary">{{ $t('common.searchText') }}</a-button>
          <a-button
            html-type="reset"
            type="default"
            @click="handleReset(formRef)"
          >{{ $t('common.resetText') }}
          </a-button
          >
        </a-space>
      </a-form-item>
    </a-form>
  </a-card>
</template>

<style lang="less" scoped>

</style>
